<!DOCTYPE html>
<html lang="en">
  
  <head>
    <meta charset="utf-8">
    <title>O2scl</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description" 
	  content="Object-oriented Scientific Computing Library">
    <link href="bootstrap.css" rel="stylesheet">
    <link href="bootstrap-responsive.css" rel="stylesheet">
  </head>

  <body>
    
    <div class="container">

      <div class="row">
	<div class="col-sm-5">
	  <h1>Why O<sub>2</sub>scl?
	  </h1>
	  <p>
	  A brief discussion of the context of this
	  object-oriented scientific computing library.
	  </p>
	</div>
	<div class="col-sm-7">
	  <p align="right">
	    &nbsp;<br>
	    <h3>
	    <a href="http://web.utk.edu/~asteine1/o2scl/html/index.html">O<sub>2</sub>scl
	    User's Guide</a></h3>
	    <a href="http://github.com/awsteiner/o2scl">O<sub>2</sub>scl 
	      at github.com</a>
	    </p>
	</div>
      </div>
      
      <hr>
      
      <div class="row">

	<div class="col-sm-3">
<!-- style="background-color: #eeeeee;"> -->

	  <p>
	    <h2><a href="#resgroup">No reinventing the wheel</a></h2>
	  </p>

	  <hr>

	  <p>
	    <h2><a href="#scicomp">Scientific computing is changing</a></h2>
	  </p>

	  <hr>

	  <p>
	    <h2><a href="#vecmat">Vectors, matrices, and other types</a></h2>
	  </p>

	  <hr>

	  <p>
	    <h2><a href="#onestop">One-stop shopping</a></h2>
	  </p>

	  <hr>

	  <p>
	    <h2><a href="wip">Get it working already!</a></h2>
	  </p>

	  <hr>

	</div>

	<div class="col-sm-9">

	  <div class="alert alert-success">
	    <a name="resgroup"></a>
	    <h2>I needed to provide a computing framework for
	      my research group. <small>(Necessity is the
		mother of invention.)</small> </h2>
	  </div>
	  <p>
	    <h4>I want my students and colleagues to be able
	      to have a head start.
	    </h4>
	  </p>
	  <ul>
	    <p>
	      <li><em>There is little point in having a student
		to rewrite old code over again when there
		are so many great new problems that need solving.</em>
	      </li>
	    </p>
	    <p>
	      <li>
		<em>I wanted something easy to install and use.</em>
	    </li></p>
	    <p>
	      O<sub>2</sub>scl takes advantage of homebrew
	      and travis-ci.org to make sure installation
	      and testing works.
	    </p>
	  </ul>
	  
	  <div class="alert alert-success">
	    <a name="scicomp"></a>
	    <h2>Scientific computing in C++ has changed significantly
	      in the past few years. <small>(Or maybe a bit more than a 
		few.)</small></h2>
	  </div>
	  <p>
	    <h4>
	    C++0x and C++11 (and their precursors in Boost) have made
	    scientific computing much easier!
	    </h4>
	  </p>
	  <ul>
	    <p>
	      <li><em>For example, lambda functions make mathematical methods much
		  easier to implement.</em></li>
	    </p>
	    <p>
	      Function objects
	      can now be defined and manipulated very succinctly:
<pre>
double a=-0.9, b=0.9;
<a href="http://o2scl.sourceforge.net/o2scl/html/classo2scl_1_1root__brent__gsl.html">o2scl::root_brent_gsl&lt;&gt;</a> solver;
std::function&lt;double(double)&gt; f=[](double x){ return sin(x)-0.1; };
solver.solve(a,b,f);
cout &lt;&lt; a &lt;&lt; endl;
</pre>
               (adapted from
                 O<sub>2</sub>scl's <tt>ex_lambda.cpp</tt>
                 example)
	    </p>
	    <p>
	      <li><em>Sometimes the best solution is a combination
		  of several different languages and libraries.</em></li>
	    </p>
	    <p>
	      Python has enabled fast development, but
	      we still want fast execution from C++. GSL
	      is great for many problems, but Fourier
	      transforms are better done in FFTW and
	      linear algebra is better implemented
	      in uBlas, Eigen, or Armadillo.
	    </p>
	  </ul>
	  
	  <div class="alert alert-success">
	    <a name="vecmat"></a>
	    <h2>Vector and matrix types have proliferated.
	      <small>(Templates can save us.)</small>
	    </h2>
	  </div>
	  <p>
	    <h4>
	      As a result of the complexity of designing a 
	      C++ linear algebra library, the current 
	      state-of-the-art consists of several C++ 
	      linear algebra libraries, each with their 
	      own distinct vector and matrix types. 
	    </h4>
	  </p>
	  <ul>
	    <li>
	      <p>
		Among these options
		are <a href="http://www.boost.org/doc/libs/release/libs/numeric/ublas/doc/index.htm">uBlas</a>,
		<a href="http://eigen.tuxfamily.org">Eigen</a>, <a href="http://arma.sourceforge.net">Armadillo</a>,
		and more. However, none of them seem to agree
		on the basics of how these objects should be
		written. For example, consider the basic 
		reallocation method, <tt>resize()</tt>. In 
		the C++11 standard, this is written 
		<pre>void <a href="http://www.cplusplus.com/reference/vector/vector/resize/">std::vector::resize</a>(size_type n)</pre> 
	      <p>
		and it is assumed that the action of <tt>resize()</tt>
		is destructive. On the other hand, in uBlas,
		resizes are <em>non-destructive</em> by default
	      </p>
	      <pre>void ublas::vector::resize(size_type n, bool preserve=true)</pre> 
	      <p>
		Armadillo vectors follow the same behavior of 
		<tt>std::vector</tt> for destructive resizes, but
		introduce a new notation for non-destructive ones
	      </p>
	      <pre>void arma::row::set_size(size_t n)</pre> 
	      Eigen operates similarly, but uses the name
	      <tt>conservativeResize()</tt> for non-destructive resizes. 
	      O<sub>2</sub>scl, for the time being, presumes that all
	      resizes are destructive, and uses a notation similar
	      to the C++11 standard for its resize methods.
	      </p>
	      <p>
		(Eventually, a set of linear algebra type traits is
		necessary to describe how linear algebra types 
		behave and how they interact with each other. )
	      </p>
	    </li>
	    <li>
	      <p>
		Obtaining rows and columns of matrices (without a copy) is
		also not trivial. In uBlas, the row of a matrix is
		obtained by using the constructor of a <tt>matrix_row</tt>
		object. In Armadillo and Eigen, this is performed by using
		the <tt>.row()</tt> method, resulting in a vector object
		of an unusual type. O<sub>2</sub>scl subsumes some of this
		complexity into a function <tt>o2scl::matrix_row</tt>,
		which can be used with any of these linear algebra
		libraries
<pre>
<span style="color: #990000">// With uBlas</span>
typedef <a href="http://www.boost.org/doc/libs/1_54_0/libs/numeric/ublas/doc/matrix.htm">boost::numeric::ublas::matrix&lt;double&gt;</a> matrix;
typedef <a href="http://www.boost.org/doc/libs/1_54_0/libs/numeric/ublas/doc/matrix_row.htm">boost::numeric::ublas::matrix_row&lt;ubmatrix&gt;</a> matrix_row;
matrix_row r1=<a href="http://o2scl.sourceforge.net/o2scl/html/namespaceo2scl.html#ae00ac0006773b47946a7ee79f3c587d0">o2scl::matrix_row</a>&lt;matrix,matrix_row&gt;(m1,2);
<span style="color: #990000">// With Eigen</span>
<a href="http://eigen.tuxfamily.org/dox/classEigen_1_1DenseBase.html#aa8716d44f51321072ee5c88665c28813">Eigen::MatrixXd::RowXpr</a> r2=
<a href="http://o2scl.sourceforge.net/o2scl/html/namespaceo2scl.html#a242ee88fabfddd0415ea9faeb376a0b4">o2scl::matrix_row</a>&lt;<a href="http://eigen.tuxfamily.org/dox/classEigen_1_1Matrix.html">Eigen::MatrixXd</a>,Eigen::MatrixXd::RowXpr&gt;(m2,2);
<span style="color: #990000">// With Armadillo</span>
<a href="http://arma.sourceforge.net/docs.html#submat">arma::subview_row</a>&lt;double&gt; m1=
<a href="http://o2scl.sourceforge.net/o2scl/html/namespaceo2scl.html#abcb2c0f0e2963e3016d8856e51d3af9c">o2scl::matrix_row</a>&lt;<a href="http://arma.sourceforge.net/docs.html#Mat">arma::mat</a>,arma::subview_row&lt;double&gt; &gt;(m3,2);
</pre>
	      </p>
	    </li>
	    <li>
	      <p>
		Heterogeneous architectures also naturally lead to 
		more data types to help contain and manipulate 
		data on them. The issues described above will likely
		become more commonplace.
	      </p>
	    </li>
	    <li>
	      <p>
		At the same time, C++ offers quite a bit of syntactic
		simplicitly, with relatively little cost in speed.
		Even though linear algebra libraries do not agree on
		the details of the interface, they can speed up
		development time considerably.
	      </p>
	    </li>
	  </ul>
	  
	  <div class="alert alert-success">
	    <a name="onestop"></a>
	    <h2>There is no &ldquo;one-stop shopping&rdquo; solution for 
	      scientific computing.
	    <small>(We try to combine several tools in a useful way.)
	      </small></h2>
	  </div>

	  <p>
	    <h4>Boost, while well-developed, doesn't provide direct
	      solutions for some basic problems, such as numerical
	      differentiation and nonlinear solving.
	    </h4>
	  </p>

	  <ul>
	    <li>
	      <p>GSL does, of course, but is more difficult to use
		with C++ member functions and generic vector types.
		Two-dimensional interpolation has only recently found
		its way into the GSL repository yet has been in
		O<sub>2</sub>scl for many years. (In fact, some GSL
		improvements were guided by O<sub>2</sub>scl
		development.)</p>
	    </li>
	    
	  </ul>

	  <div class="alert alert-success">
	    <a name="wip"></a>
	    <h2>O<sub>2</sub>scl is a work-in-progress.
	    <small>(Help me Obi-Wan!)</small></h2>
	  </div>

	  <p>
	    <h4>
	      O<sub>2</sub>scl attempts to be a path towards a
	      general-purpose C++ scientific computing library which
	      enables easier and faster development.
	    </h4>
	  </p>
	  <ul>
	    <li>
	      <p>
		O<sub>2</sub>scl is still in beta, so this is a
		perfect time to let me know if it is useful to you (or
		not), and feel free to make comments or suggestions.
	      </p>
	    </li>
	  </ul>
	  <!-- End of "col-sm-9" -->
	</div>
	
	<!-- End of row -->
      </div>

      <!-- End of container -->
    </div>

    <hr>
    <small>
      &nbsp;&nbsp;&nbsp;&nbsp;Built 
      with <a href="http://getbootstrap.com">Bootstrap</a>.
    </small>
    
    <!-- 

	 File I/O is more sophisticated and more important
	 - HDF5 I/O is one of many well-trodden standards
	 - Open data means file formats are important

	 New dogs can learn old tricks
	 - Some legacy code in Fortran is rewritten in C++
	 - Several classes are based on GSL

	 Documentation is important

	 * mroot_hybrids example
	 * funct_strings11 example
	 * root_brent_gsl vs. root_boost_toms748
	 * Talk about --disable-cpp11
	 * HDF5 example?
	 * interp2_direct example
	 * Good cernlib example
	 * Talk about compilation on hopper, edison, and carver
	 
      -->
    
    <script src="jquery-2.0.3.min.js"></script>
    <script src="bootstrap.js"></script>

  </body>
  
</html>
